import {NgModule, ModuleWithProviders} from "@angular/core";
import {HttpHelper} from "./httpHelper";
import {DefaultDataCacheStrategy, DataCacheStrategy} from "./dataCacheStrategy";
import {HttpClientModule} from "@angular/common/http";
@NgModule({
    imports: [
        HttpClientModule,
    ],
    providers: [
        HttpHelper,           // http帮助
        {provide: DataCacheStrategy, useClass: DefaultDataCacheStrategy}
    ]
})
export class ServiceModule {
    static forRoot(apiUrl: string): ModuleWithProviders {
        return {
            ngModule: ServiceModule,
            providers: [
                {provide: "apiUrl", useValue: apiUrl}
            ]
        }
    }
}
